$(function () {
  //加载数据
  var $tbWork = $('#tbWork'), $pager = $('#tbWorkPager');
  $tbWork.jqGrid({
    url: indexwork_urls.getWork,
    datatype: 'json',
    mttype: 'post',
    colNames: ['工单号', '车牌号', '客户', '接待人','维修技师','操作'],
    colModel: [
      {name: 'num', index: 'num', width: '100', align: 'center'},
      {name: 'car_num', index: 'car_num', width: '100', align: 'center'},
      {name: 'client_name', index: 'client_name', width: '100', align: 'center'},
      {name: 'reception_name', index: 'reception_name', width: '100', align: 'center'},
      {name: 'repairman_name', index: 'repairman_name', width: '100', align: 'center'},
      {
        name: 'id', index: 'id', width: '100', align: 'center',
        formatter: function (value, options, obj) {
          return '<a style="cursor:pointer;" onclick="indexWork.modifyWork('+value+');">完善工单</a>';
        }
      },
    ],
    height: 'auto',
    pager: '#tbWorkPager',
    viewrecords: true,
    rowNum: 10,
    rowList: [10, 20, 40],
    autowidth: true
  });
  // 隐藏水平方向滚动条
  $tbWork.closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" });
});
indexWork = {
  search: function () {
    var $fmQuery = $('.fmWorkQuery-hook');
    var param = ittaoli.serializeObject($fmQuery);
    $('#tbWork').jqGrid('setGridParam', {
      postData: {q: JSON.stringify(param)},
      page: 1
    }).trigger("reloadGrid");
  },
  searchNull: function () {
    $('.fmWorkQuery-hook input').val('');
    var param = {};
    $('#tbWork').jqGrid('setGridParam', {
      postData: {q: JSON.stringify(param)},
      page: 1
    }).trigger("reloadGrid");
  },

  modifyWork:function(id){
    window.location.href='/admin/work/modifywork/id/'+id;
  }
};